﻿
Imports SponsorshipLogic
Imports SponsorshipLogic.Activity


Public Class RecentActivityManager
    Private WithEvents _RecentActivitylistCtrl As ctlRecentActivity
    Public Sub New()

    End Sub

    Public Sub New(ByVal RecentActivitylistCtrl As ctlRecentActivity)
        _RecentActivitylistCtrl = RecentActivitylistCtrl
        _RecentActivitylistCtrl.ActivityTypes = ActivityTypes()
        Fill()
    End Sub
    Public Sub Fill()
        Dim dt As New DataTable
        Const Activities As Integer = 20
        If Not _RecentActivitylistCtrl Is Nothing And Not User.CurrentUser Is Nothing Then
            dt = User.CurrentUser.Activity.RecentActivity(Activities, _RecentActivitylistCtrl.ActivityTypeFilter)
            _RecentActivitylistCtrl.DataTable = dt
        End If
    End Sub

    Private Sub _RecentActivitylistCtrl_OpenActivity(ByVal ActivityType As SponsorshipLogic.Activity.ActivityType, ByVal ActivityId As Integer) Handles _RecentActivitylistCtrl.OpenActivity


        Select Case ActivityType

            Case Is = ActivityType.atChild
                Dim fChild As New frmChild
                fChild.Show()
                fChild.Id = ActivityId


            Case Is = ActivityType.atFamily
                MessageBox.Show("Family form : Id " & ActivityId)

            Case Is = ActivityType.atParent
                MessageBox.Show("Parent form : Id " & ActivityId)


            Case Is = ActivityType.atRelationship
                MessageBox.Show("Child form : Id " & ActivityId)

            Case Is = ActivityType.atSponsor
                MessageBox.Show("Adopter form : Id " & ActivityId)


            Case Is = ActivityType.atUnknown
                MessageBox.Show("Activity Type Unknown")



        End Select




    End Sub

    Private Sub _RecentActivitylistCtrl_Reload() Handles _RecentActivitylistCtrl.Reload
        Fill()
    End Sub
End Class
